package xy.donate.android.constant

import java.util.*

object Constant {

    var transacation = 0
    //用户头像
    const val USER_HEADER = "user_header"
    //用户地址
    const val USER_ADDRESS = "user_address"
    //用户id
    const val USER_ID_NUM = "user_id_num"
    //用户昵称
    const val USER_NAME = "user_name"
    //用户手机号
    const val USER_PHONE = "user_phone"
    //开眼
    const val URL_OPEN_EYE = "base_url:kaiyanapp"
    //申请记录表名
    const val RECORD_TABLE = "hands_up_record_table"
    //聊天信息
    const val CHAT_INFO = "chat_info"

    //生成唯一ID
    fun getUUID():String{
        return UUID.randomUUID().toString().replace("-", "")
    }

    //生成订单号  两位随机字符+年份(后两位)+月+日+时+分+自增参数
    fun getOrderNo():String{
        val first = (Random().nextInt(26) + 65).toChar().toString()
        val second = (Random().nextInt(26) + 65).toChar().toString()
        val calendar = Calendar.getInstance()
        val year = calendar.get(Calendar.YEAR)
        val month = calendar.get(Calendar.MONTH) + 1
        val day = calendar.get(Calendar.DAY_OF_MONTH)
        val hour = calendar.get(Calendar.HOUR_OF_DAY)
        val minute = calendar.get(Calendar.MINUTE)
        val m = calendar.get(Calendar.MILLISECOND)

        if (transacation in (0..9998)) {
            transacation += 1
        } else if (transacation == 9999) {
            transacation = 0
        }
        val trans = String.format("%0" + 4 + "d", transacation)
        val mon = String.format("%0" + 2 + "d", month)
        val days = String.format("%0" + 2 + "d", day)
        val hou = String.format("%0" + 2 + "d", hour)
        val min = String.format("%0" + 2 + "d", minute)

        val str = StringBuffer("")
        str.append(first).append(second).append(year % 100).append(mon).append(days).append(hou).append(min).append(m).append(trans)

        return str.toString()
    }

    //Date格式
    const val DATE_FORMAT_LINK = "yyyyMMddHHmmssSSS"

    //Date格式 常用
    const val DATE_FORMAT_DETACH = "yyyy-MM-dd HH:mm:ss"

    const val DATE_FORMAT_DETACH_CN = "yyyy年MM月dd日 HH:mm:ss"

    const val DATE_FORMAT_DETACH_CN_SSS = "yyyy年MM月dd日 HH:mm:ss SSS"

    const val DATE_FORMAT_DETACH_CN_DD = "yyyy-MM-dd"

    //Date格式 带毫秒
    const val DATE_FORMAT_DETACH_SSS = "yyyy-MM-dd HH:mm:ss SSS"
}